<?php
/**
 * Created by PhpStorm.
 * User: kaycn
 * Date: 18-9-18
 * Time: 下午9:45
 */

require "../vendor/autoload.php";

use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverExpectedCondition;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;

// start Firefox with 5 second timeout
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = DesiredCapabilities::chrome();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
$driver->get('https://www.alipay.com/');

$element = $driver->findElement(WebDriverBy::cssSelector('.title>.personal'));

$driver->executeScript("arguments[0].click();", [$element]);

sleep(2);
$i = 1;

$js = <<<js
    var a = document.getElementsByClassName("channel-a");
    return a[{$i}].innerText;
js;

echo $driver->executeScript($js);

